#include "hplczkyssendcommonpacket.h"
#include "hplczkyspfcid.h"
#include "hplczkysprotocolcommondata.h"
#include "hplczkysmakepacket.h"
#include "hplczkyscheckpacket.h"

namespace hplc
{
namespace zkys
{

HplcZkysSendCommonPacket::HplcZkysSendCommonPacket(HplcZkysProtocolCommonData &data, QObject *parent)
    : BaseSendPacket (data, parent)
{
    m_d = &data;
}

HplcZkysSendCommonPacket::~HplcZkysSendCommonPacket()
{

}

void HplcZkysSendCommonPacket::setDeviceAddress(quint8 address)
{
    HplcZkysProtocolCommonData *m_d = static_cast<HplcZkysProtocolCommonData*>(this->m_d);
    m_d->m_maker->makeGlobalPacket(SET_PFC(PFC_GLOBAL_DEVICE_ADDRESS), address);
    m_d->m_checker->sendRetry();
}

void HplcZkysSendCommonPacket::getDeviceAddress()
{
    HplcZkysProtocolCommonData *m_d = static_cast<HplcZkysProtocolCommonData*>(this->m_d);
    m_d->m_maker->makeGlobalPacket(GET_PFC(PFC_GLOBAL_DEVICE_ADDRESS));
    m_d->m_checker->sendRetry();
}

void HplcZkysSendCommonPacket::getSoftwareVersion()
{
    HplcZkysProtocolCommonData *m_d = static_cast<HplcZkysProtocolCommonData*>(this->m_d);
    m_d->m_maker->makePacket(GET_PFC(PFC_GLOBAL_SOFTWARE_VERSION));
    m_d->m_checker->sendRetry();
}

void HplcZkysSendCommonPacket::getHardwareVersion()
{
    HplcZkysProtocolCommonData *m_d = static_cast<HplcZkysProtocolCommonData*>(this->m_d);
    m_d->m_maker->makePacket(GET_PFC(PFC_GLOBAL_HARDWARE_VERSION));
    m_d->m_checker->sendRetry();
}

void HplcZkysSendCommonPacket::getProductDate()
{
    HplcZkysProtocolCommonData *m_d = static_cast<HplcZkysProtocolCommonData*>(this->m_d);
    m_d->m_maker->makePacket(GET_PFC(PFC_GLOBAL_PRODUCT_DATE));
    m_d->m_checker->sendRetry();
}

void HplcZkysSendCommonPacket::getSerialNumber()
{
    HplcZkysProtocolCommonData *m_d = static_cast<HplcZkysProtocolCommonData*>(this->m_d);
    m_d->m_maker->makePacket(GET_PFC(PFC_GLOBAL_SERIAL_NUMBER));
    m_d->m_checker->sendRetry();
}

void HplcZkysSendCommonPacket::getModel()
{
    HplcZkysProtocolCommonData *m_d = static_cast<HplcZkysProtocolCommonData*>(this->m_d);
    m_d->m_maker->makePacket(GET_PFC(PFC_GLOBAL_MODEL));
    m_d->m_checker->sendRetry();
}

void HplcZkysSendCommonPacket::getUsedTime()
{
    HplcZkysProtocolCommonData *m_d = static_cast<HplcZkysProtocolCommonData*>(this->m_d);
    m_d->m_maker->makePacket(GET_PFC(PFC_GLOBAL_USED_TIME));
    m_d->m_checker->sendRetry();
}

void HplcZkysSendCommonPacket::setSyncTime(quint32 time)
{
    HplcZkysProtocolCommonData *m_d = static_cast<HplcZkysProtocolCommonData*>(this->m_d);
    m_d->m_maker->makePacket(SET_PFC(PFC_GLOBAL_SYNC_TIME), time);
    m_d->m_checker->sendRetry();
}

void HplcZkysSendCommonPacket::getSyncTime()
{
    HplcZkysProtocolCommonData *m_d = static_cast<HplcZkysProtocolCommonData*>(this->m_d);
    m_d->m_maker->makePacket(GET_PFC(PFC_GLOBAL_SYNC_TIME));
    m_d->m_checker->sendRetry();
}

void HplcZkysSendCommonPacket::getInput(quint8 inputNum)
{
    HplcZkysProtocolCommonData *m_d = static_cast<HplcZkysProtocolCommonData*>(this->m_d);
    m_d->m_maker->makePacket(GET_PFC(PFC_GLOBAL_INPUT), inputNum);
    m_d->m_checker->sendRetry();
}

void HplcZkysSendCommonPacket::setOutput(quint8 outputNum, quint8 level)
{
    HplcZkysProtocolCommonData *m_d = static_cast<HplcZkysProtocolCommonData*>(this->m_d);
    m_d->m_maker->makePacket(SET_PFC(PFC_GLOBAL_OUTPUT), outputNum, level);
    m_d->m_checker->sendRetry();
}

void HplcZkysSendCommonPacket::getOutput(quint8 outputNum)
{
    HplcZkysProtocolCommonData *m_d = static_cast<HplcZkysProtocolCommonData*>(this->m_d);
    m_d->m_maker->makePacket(GET_PFC(PFC_GLOBAL_OUTPUT), outputNum);
    m_d->m_checker->sendRetry();
}

void HplcZkysSendCommonPacket::setTick()
{
    HplcZkysProtocolCommonData *m_d = static_cast<HplcZkysProtocolCommonData*>(this->m_d);
    m_d->m_maker->makePacket(SET_PFC(PFC_GLOBAL_TICK));
    m_d->m_checker->sendNoRetry();
}

void HplcZkysSendCommonPacket::setTickPeriod(quint8 period)
{
    HplcZkysProtocolCommonData *m_d = static_cast<HplcZkysProtocolCommonData*>(this->m_d);
    m_d->m_maker->makePacket(SET_PFC(PFC_GLOBAL_TICK_PERIOD), period);
    m_d->m_checker->sendRetry();
}

void HplcZkysSendCommonPacket::getTickPeriod()
{
    HplcZkysProtocolCommonData *m_d = static_cast<HplcZkysProtocolCommonData*>(this->m_d);
    m_d->m_maker->makePacket(GET_PFC(PFC_GLOBAL_TICK_PERIOD));
    m_d->m_checker->sendRetry();
}

void HplcZkysSendCommonPacket::getSystemError()
{
    HplcZkysProtocolCommonData *m_d = static_cast<HplcZkysProtocolCommonData*>(this->m_d);
    m_d->m_maker->makePacket(GET_PFC(PFC_GLOBAL_ERROR));
    m_d->m_checker->sendRetry();
}

void HplcZkysSendCommonPacket::setSystemErrorUploadFreq(quint8 freq)
{
    HplcZkysProtocolCommonData *m_d = static_cast<HplcZkysProtocolCommonData*>(this->m_d);
    m_d->m_maker->makePacket(SET_PFC(PFC_GLOBAL_ERROR_UPLOAD_FREQ), freq);
    m_d->m_checker->sendRetry();
}

void HplcZkysSendCommonPacket::getSystemErrorUploadFreq()
{
    HplcZkysProtocolCommonData *m_d = static_cast<HplcZkysProtocolCommonData*>(this->m_d);
    m_d->m_maker->makePacket(GET_PFC(PFC_GLOBAL_ERROR_UPLOAD_FREQ));
    m_d->m_checker->sendRetry();
}

} // zkys
} // hplc
